package com.heima.demo;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class Demo {
    public static void main(String[] args) {
        AtomicInteger ac = new AtomicInteger(10);
        System.out.println(ac.get());
        AtomicInteger ac1 = new AtomicInteger(10);
        int andAccumulate = ac1.getAndIncrement();
        System.out.println(andAccumulate);
        System.out.println(ac1.get());
        AtomicInteger ac2= new AtomicInteger(10);
        int i = ac2.incrementAndGet();
        //自增后的值
        System.out.println(i);
        System.out.println(ac2.get());
        AtomicInteger ac3 = new AtomicInteger(10);
        ac3.addAndGet(20);
        System.out.println(i);
        System.out.println(ac3.get());
        AtomicInteger ac4 = new AtomicInteger(100);
        int andSet = ac4.getAndSet(20);
        System.out.println(andSet);
        System.out.println(ac4.get());


    }
}
